<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>巡检管理</title>
		<link rel="stylesheet" href="../../js/plugins/layui-v2.4.5/layui/css/layui.css" />
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/list.css" />
	</head>
	<body class="p10">
		<div class="container p15">
			<div class="btn-container"><a href="javascript:;" id="addBtn" class="layui-btn layui-btn-sm">添加</a></div>
			<table id="list" lay-filter="list"></table>
		</div>
		<script src="../../js/jquery-3.3.1.min.js"></script>
		<script src="../../js/plugins/layui-v2.4.5/layui/layui.js"></script>
		<script>
			var data = [{
					id: 1,
					name: '网络机房巡检',
					cycle: '2小时',
					startTime: '2019.1.1 0:00',
					endTime: '2019.12.31 24:00',
					position:'网络机房',
					hasDuty:false
				}
			];
			layui.use(['table'],function(){
				var table = layui.table;
				//第一个实例
				  table.render({
					elem: '#list'
					,height: '300'
					,url: '' //数据接口
					,page: true //开启分页
					,cols: [[ //表头
					  	{
					  		field: 'xh',
					  		title: '序号',
					  		width: 80,
					  		align: 'center',
					  		templet: function(d) {
					  			return d.LAY_INDEX;
					  		}
					  	}, {
					  		field: 'name',
					  		title: '计划名称',
					  		align: 'center'
					  	}, {
					  		field: 'cycle',
					  		title: '巡回周期',
					  		align: 'center'
					  	}, {
					  		field: 'startTime',
					  		title: '开始时间',
					  		align: 'center'
					  	}, {
					  		field: 'endTime',
					  		title: '结束时间',
					  		align: 'center'
					  	}, {
					  		field: 'position',
					  		title: '巡检位置',
					  		align: 'center'
					  	}, {
					  		field: 'hasDuty',
					  		title: '关联值班',
					  		align: 'center',
							templet:function(d){
								if(d.hasDuty){
									return `<a href="javascript:;" onclick="setDuty()"><span class="layui-btn layui-btn-primary layui-btn-xs">已关联</span></a>`
								}else{
									return `<a href="javascript:;" onclick="setDuty()"><span class="layui-btn layui-btn-warm layui-btn-xs">未关联</span></a>`
								}
							}
					  	}, {
					  		field: 'opt',
					  		title: '操作',
					  		width: 160,
					  		align: 'center',
					  		templet: function(d) {
					  			return `<a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs"><i class="layui-icon layui-icon-edit"></i>编辑</a>
					  					  &nbsp;<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon layui-icon-delete"></i>删除</a>`
					  		}
					  	}
					]]
					,data:data
				  });
			})
			$(function(){
				$("#addBtn").click(function(){
					top.tabAdd('巡检新增','xunjian_add','pages/xunjian/xunjian_add.html',true,true);
					
				})
			})
			function setDuty(){
				layui.layer.open({
					title:['巡检关联','font-size:16px;text-align:center'],
					type:2,
					content:'duty_sel.html',
					area:['800px','450px']
				})
			}
		</script>
	</body>
</html>
